package com.lsh.serializable;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author ：LiuShihao
 * @date ：Created in 2021/4/9 12:40 下午
 * @desc ：
 */
public class TestUserInfo {

    /**
     * 先调用两种编码接口对UserInfo对象编码，然后分别打印两者编码后的码流的大小
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        UserInfo userInfo = new UserInfo("Welcomde to Netty",100);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream os = new ObjectOutputStream(bos);
        os.writeObject(userInfo);
        os.flush();
        os.close();
        byte[] b = bos.toByteArray();
        System.out.println("The jdk serializable length is :"+b.length);
        bos.close();
        System.out.println("------------------------------------------");
        System.out.println("The byte array serializable length is :"+userInfo.codeC().length);

    }
}
